import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt(),m=sc.nextInt();
        String[] str=new String[n];
        char[][] arr=new char[n][m];
        int[][] dp=new int[n+1][m+1];
        for(int i=0;i<n;i++){
            str[i]=sc.next();
        }
        for(int i=1;i<=n;i++){
            char[] ch=str[i].toCharArray();
            for(int j=1;j<=m;j++){
                arr[i][j]=ch[j-1];
            }
        }
        for(int i=0;i<=n;i++){
            for(int j=0;j<=m;j++){
                int t=0;
                if(arr[i][j]=='l') t=4;
                else if(arr[i][j]=='o') t=3;
                else if(arr[i][j]=='v') t=2;
                else if(arr[i][j]=='e') t=1;
                dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1])+t;
            }
        }
        System.out.println(dp[n][m]);
    }

    public static void main1(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt(),b=sc.nextInt();
        long num=a*b/minNum(a,b);
        System.out.println(num);
    }
    public static int minNum(int a,int b){
        int t;
        while(b!=0){
            t=a%b;
            a=b;
            b=t;
        }
        return a;
    }
}